// copyright
package com.cicadamob.contact.api.group.asynctask;

import java.util.List;

import com.cicadamob.contact.api.group.dao.Group_Db_Dao;
import com.cicadamob.contact.api.service.Contact;

import android.content.Context;
import android.os.AsyncTask;
import android.os.Handler;
import android.os.Message;


/**
 * 类的描述: 群组列表搜索
 * @author  
 * @version 创建时间：2014-3-25 下午7:39:35 
 */
public class AsyncGroupSearchTask extends
		AsyncTask<String, Void, List<Contact>> {

	private Group_Db_Dao groupDao;
	private Context context;
	private Handler handler;
	/** 群组搜索成功 **/
	public static final int AsyncGroupSearchSuccess = 1000;

	public AsyncGroupSearchTask(Context context, Handler handler) {
		this.context = context;
		this.handler = handler;
		groupDao = Group_Db_Dao.getInstance(context);
	}

	@Override
	protected List<Contact> doInBackground(String... params) {
		List<Contact> contacts = null;
		try {
			contacts = groupDao.queryByContactForGroupSelect(params[0],
					false);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return contacts;
	}

	@Override
	protected void onPostExecute(List<Contact> result) {
		if(result != null){
			Message msg = new Message();
			msg.what = AsyncGroupSearchSuccess;
			msg.obj = result;
			handler.sendMessage(msg);
			
		}
	}
}
